<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{/layout}">
<head>
    <meta charset="UTF-8">
    <title>test</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/jquery.bootstrapvalidator/0.5.3/css/bootstrapValidator.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery.bootstrapvalidator/0.5.3/js/bootstrapValidator.min.js"></script>
</head>
<body>
<!--个人信息 -->
<div class="col-lg-8 col-lg-offset-2" style="padding-top: 40px">
    <form class="form-horizontal" method="post" action="" id="classes-form">
        <div class="box-body">
            <div class="form-group">
                <label for="inputName" class="col-sm-2 col-sm-offset-1 control-label">商品价格</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="price" id="inputName"
                           placeholder="请输入商品价格">
                </div>
            </div>
        </div>
    </form>
</div>

<script>
    $(function () {
        $('#classes-form').bootstrapValidator({
            live : 'enabled', //enabled代表当表单控件内容发生变化时就触发验证，默认提交时验证，
            // disabled和submitted代表当点击提交按钮时触发验证

            feedbackIcons: {  //显示表单验证结果的图标
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                price: {
                    validators: {
                        numeric: {
                            message: '价格必须为数值'
                        }
                    }
                }
            }
        })
    })
</script>
</body>
</html>